package io.github.talelin.latticy.service.feign;

import io.github.talelin.latticy.dto.admin.ResetPasswordDTO;
import io.github.talelin.latticy.dto.feign.QueryUsersByIdsDTO;
import io.github.talelin.latticy.dto.omsuser.UpdateOmsUserDTO;
import io.github.talelin.latticy.dto.query.BasePageDTO;
import io.github.talelin.latticy.dto.user.RegisterDTO;
import io.github.talelin.latticy.model.UserDO;
import io.github.talelin.latticy.vo.DeletedVO;
import io.github.talelin.latticy.vo.PageResponseVO;
import io.github.talelin.latticy.vo.UpdatedVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Positive;
import java.util.List;

/**
 * @authoer:wulongbo
 * @createDate:2022/5/25
 * @description:
 */
@FeignClient(value = "oms-server")
public interface OpenFeignService {

    /**
     * 参数默认是@RequestBody标注的，这里的@RequestBody可以不填
     * 方法名称任意
     * OMS用户注册
     */
    @PostMapping("/user/openfeign/register")
    UserDO registerOmsUser(@RequestBody RegisterDTO registerDTO);

    /**
     * 根据用户id获取OMS用户信息
     */
    @GetMapping("/user/openfeign/user/{id}")
    UserDO getOmsUserById(@PathVariable("id") Integer id);

    /**
     * 根据用户id获取OMS用户信息包含删除（用于日志记录）
     */
    @GetMapping("/user/openfeign/user/log/{id}")
    UserDO getOmsUserAfterLogById(@PathVariable("id") Integer id);

    /**
     * 根据用户id查询OMS用户列表
     */
    @GetMapping("/user/openfeign/getUsersByIds")
    PageResponseVO<UserDO> getOmsUsersByOmsUserIds(@Validated @SpringQueryMap QueryUsersByIdsDTO dto);

    /**
     * 获取OMS所有非Root用户信息(非分页)
     */
    @GetMapping("/user/openfeign/list")
    List<UserDO> getOmsUserList();

    /**
     * 获取OMS所有非Root用户信息
     */
    @GetMapping("/user/openfeign/users")
    PageResponseVO<UserDO> getOmsUsers(@Validated @SpringQueryMap BasePageDTO dto);

    /**
     * 修改OMS用户信息
     *
     * @param id
     * @param validator
     * @return
     */
    @PutMapping("/user/openfeign/{id}")
    UpdatedVO updateOmsUser(@PathVariable @Positive(message = "{id.positive}") Integer id,
                            @RequestBody @Validated UpdateOmsUserDTO validator);

    /**
     * 删除OMS用户信息
     */
    @DeleteMapping("/user/openfeign/{id}")
    DeletedVO delOmsUserById(@PathVariable("id") Integer id);

    @PutMapping("/cms/admin/user/{id}/password")
    UpdatedVO changeOmsUserPassword(@PathVariable @Positive(message = "{id.positive}") Integer id, @RequestBody @Validated ResetPasswordDTO validator);

    /**
     * 获取admin分组id
     */
    @GetMapping("/user/openfeign/getAdminGroupId")
    List<Integer> getAdminGroupId();
}
